#! /bin/sh
####################################################################################
#                                                                                  #
#  Copyright (c) 1996, Sun Microsystems Computer Corporation, Mountain View, CA    #
#                                                                                  #
#                      All Rights Reserved                                         #
#                                                                                  #
# Sun Microsystems Computer Corporation disclaims all warranties with              #
# regard to this software, including all implied warranties of merchantability     #
# and fitness.  In no event will Sun Microsystems Inc., Sun Microsystems           #
# Computer Corporation or any Sun Microsystems Inc. company, its employees         #
# or agents be liable for direct, incidental or consequential damages              #
# resulting from loss of data or business opportunities, resulting from the        #
# Ultracomputing Demo CD, or any part of same, either alone or in conjunction      #
# with other programs.                                                             #
#                                                                                  #
# The software contained on these discs is distributed as is, at no additional     #
# charge. As such, it is excluded from any pre-existing customer service 	   #
# or support agreements with Sun Microsystems. An email form is provided in 	   #
# the main demo menu to direct comments, feedback and technical questions          #
# relating strictly to Ultrapack, the demos and usage thereof.			   #
#                                                                                  #
# install.sh:									   #
#                                                                                  #
# Executable shell script for installing the UltraPack				   #
# 		SMCC Desktop Systems Engineering				   #
#		March 1996				   			   #
#										   #
####################################################################################
#set -x

FALSE=0
TRUE=1

if [ "$ULTRA_PACK_HOME" != "" ]; then
	cd $ULTRA_PACK_HOME;
else
	echo "Please setenv ULTRA_PACK_HOME";
fi

/bin/clear
echo " "
echo "Ultra Pack install utility..."
echo " "
echo " "
echo " "
echo "This utility will install the demos to destination directory which you"
echo "must have permission to write to. You can perform a full install, which"
echo "will copy all the files from the UltraPack Sun demo CD, or you can"
echo "choose a light install, which will copy all of the binaries and"
echo "necessary files, but with fewer data files..."
echo " "
echo "	1. light (~204 Mb)"
echo " "
echo "	2. full  (~332 Mb)"
echo " "
echo "	3. Quit"
echo " "
read reply

if [ "$reply" = "1" ]; then
	echo " "
	echo "Light install selected..."
	echo " "
	INSTALL_LIGHT=$TRUE;
elif
[ "$reply" = "2" ]; then
	echo " "
	echo "Full install selected..."
	echo " "
	INSTALL_LIGHT=$FALSE;
else
	exit;
fi

echo " "
echo "Enter path to install..."
read instpath

if [ "$instpath" = "" ]; then
	echo "Must specify a pathname";
	echo "Exiting";
	/usr/bin/sleep 2;
	exit;
fi

if [ ! -d $instpath ]; then
	echo " ";
	echo "Path does not exist, create (y/n)";
	read reply;

	if [ "$reply" = "y" ] || ["$reply" = "Y" ] ; then
	    mkdir $instpath;
	elif
	[ "$reply" = "n" ] || ["$reply" = "N" ] ; then
	    echo "Exiting";
	    sleep 2
	    exit;
	fi
fi

if [ ! -w $instpath ]; then
    echo " ";
    echo "Permission denied"
    echo "Exiting ";
    sleep 2
    exit
fi

if [ $INSTALL_LIGHT -eq $TRUE ]; then
	/usr/bin/tar cvfX - $ULTRA_PACK_HOME/WWW/exclude.light . | (cd $instpath; tar xf - )
else
	/usr/bin/tar cvfX - $ULTRA_PACK_HOME/WWW/exclude.full . | (cd $instpath; tar xf - )
fi

# Embed the install path into the run_demo script...
tmpfil=/tmp/.iU_d_$$
sed -e "s;/cdrom/cdrom0;$instpath;g" -e "s;^#ULTRA_PACK_HOME=;ULTRA_PACK_HOME=;" $instpath/run_demo > $tmpfil
mv $tmpfil $instpath/run_demo
chmod 755 $instpath/run_demo
#
#
/bin/sleep 2
/bin/clear
echo " "
echo "The UltraPack demos have been successfully installed to:" 
echo " "
echo $instpath
echo " "
echo "To run the demo's, double click on the run_demo icon"
echo "with File Manager in " $instpath
echo " "
echo "...or, to run from Unix command line, you need to include the path"
echo $instpath "in your shell search path"
echo " "
echo "Press any key to exit install"
read replay
